<?php
declare (strict_types = 1);
/**
 * +----------------------------------------------------------------------
 * | 管理员日志控制器
 * +----------------------------------------------------------------------
 */
namespace app\controller\sys;

// 引入框架内置类
use think\facade\View;

use app\model\System as SystemModel;
use app\utils\ReUtils;

class System extends Base
{
    public function index()
    {
        $data = SystemModel::find(1);

        View::assign('data', $data);

        return View::fetch();
    }

    public function save()
    {
        if ($this->request->isPost()) {

            $params = $this->request->param();

            $params['message_send_mail'] = isset($params['message_send_mail']) && ($params['message_send_mail']==1) ? 1 : 0;

            try {
                SystemModel::saveData($params);
            } catch (\Exception $e) {
                $msg = $e->getMessage();

                return ReUtils::error("错误提示:" . $msg);
            }
            return ReUtils::success("保存成功");
        }
    }
}
